package com.yjy.fuyao.stu.controller.admin;


import com.yjy.fuyao.stu.entity.form.VideoInfo;
import com.yjy.fuyao.stu.service.VideoService;
import com.yjy.fuyao.utils.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author yjy
 * @since 2021-08-17
 */
@Api(tags="课时管理")
@RestController
@RequestMapping("/admin/stu/video")
public class AdminVideoController {

    @Resource
    VideoService videoService;

    @ApiOperation(value = "保存视频")
    @PostMapping("/save")
    public R saveOrUpdateVideoInfo(
            @ApiParam(name = "video",value = "视频对象", required = true)
            @RequestBody VideoInfo videoInfo){
        boolean result = videoService.saveOrUpdateVideoInfo(videoInfo);
        return R.ok();
    }

    @ApiOperation(value = "获取视频")
    @GetMapping("/get/{id}")
    public R getVideoInfoById(
            @ApiParam(name = "id",value = "视频Id", required = true)
            @PathVariable String id){
        VideoInfo videoInfo = videoService.getVideoInfoById(id);
        return R.ok().data("item",videoInfo);
    }

    @ApiOperation(value = "删除视频")
    @DeleteMapping("/remove")
    public R removeById(
            @ApiParam(name = "id",value = "视频Id", required = true)
            @RequestParam("id") String id){
        videoService.removeByVideoId(id);
        return R.ok();
    }

}

